/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.minidota.model;

import com.minidota.game.Room;
import com.minidota.utils.Util;

/**
 *
 * @author custom
 */
public abstract class BaseObject {

    private int gameId = -1;
    private Vector2 position = new Vector2();
    private int viewAngle = 0;
    private int teamId;
    private int radius = 50; //радиус колизии
    private double HP; //здоровье
    private Room room; //есть методы проверки может ли етот юзер ступить дальше
    public final Vector2 getPosition() {
        return position;
    }

    public final void setPosition(Vector2 position) {
        this.position = position;
    }

    public void updateData(long tick) {
    }

    /**
     * @return возвращает данные об объекте клиенту
     */
    public String getSendData() {
        StringBuilder sb = new StringBuilder();

        sb.append(Util.getCharByCode((int) Math.round(getPosition().getX() * 10)));

        sb.append(Util.getCharByCode((int) Math.round(getPosition().getY() * 10)));

        return sb.toString();
    }

    /**
     * @return возвращает данные об объекте клиенту для мини-карты
     */
    public String getMiniData() {
        return "";
    }

    public boolean isFreePoint(double nx, double ny) {
        return true;
    }

    /**
     * @return the viewAngle
     */
    public int getViewAngle() {
        return viewAngle;
    }

    /**
     * @param viewAngle the viewAngle to set
     */
    public void setViewAngle(int viewAngle) {
        this.viewAngle = viewAngle;
    }

    /**
     * @return the gameId
     */
    public int getGameId() {
        return gameId;
    }

    /**
     * @param gameId the gameId to set
     */
    public void setGameId(int gameId) {
        this.gameId = gameId;
    }

    /**
     * @return the teamId
     */
    public int getTeamId() {
        return teamId;
    }

    /**
     * @param teamId the teamId to set
     */
    public void setTeamId(int teamId) {
        this.teamId = teamId;
    }

    /**
     * @return the radius
     */
    public int getRadius() {
        return radius;
    }

    /**
     * @param radius the radius to set
     */
    public void setRadius(int radius) {
        this.radius = radius;
    }

    /**
     * @return возвращает true, если игрок жив
     */
    public boolean isAlive() {
        return this.getHP() > 0;
    }

    /**
     * @return the HP
     */
    public double getHP() {
        return HP;
    }

    /**
     * @param HP the HP to set
     */
    public void addHP(double HP) {
        this.HP += HP;
    }

    /**
     * @param HP the HP to set
     */
    public void setHP(double HP) {
        this.HP = HP;
    }

    public void doDamage(BaseObject attacker, double damage) {
    }

    public int getDamage() {
        return 0;
    }

    /**
     * @return the room
     */
    public Room getRoom() {
        return room;
    }

    /**
     * @param room the room to set
     */
    public void setRoom(Room room) {
        this.room = room;
    }
}
